<?php
include_once "model.php";
try {
	$story = $model->get_story(1);
	$random = $model->get_random_from_queue(1);
	$left = $model->get_node($random[LEFT_NODE_ID]);
	$right = $model->get_node($random[RIGHT_NODE_ID]);
}
catch (Exception $e) {
	echo $e->getMessage();
//	header('Location: /fractal-narratives/error.php');
}

?>
<?
include("inc/header.inc");
?>
<h1><?=$story[S_TITLE]?></h1>
<p><?=$left[NODE_CONTENT]?></p>
	<form action="add.php" method="post">
		<textarea name="<?=NODE_CONTENT?>" id="inputbox" maxlength="640" placeholder="Write the middle of this story" autocomplete="off"></textarea>
		<div class="submitbox"><span><a href="about.php">what do I do?</a></span> <span id="fn-counter">500</span> <input class="btnsubmit" type="submit" value="Submit" /></div>
		<input type="hidden" name="<?=Q_ID?>" value="<?=$random[Q_ID]?>" />
		<input type="hidden" name="<?=Q_LOCKED_UNTIL?>" value="<?=$random[Q_LOCKED_UNTIL]?>" />
	</form>
<p><?=$right[NODE_CONTENT]?></p>

<?
include("inc/footer.inc");
?>
